<!-- FlipUnit.vue -->
<template>
    <div class="flip-unit">
      <transition name="flip" mode="out-in">
        <div :key="formattedValue" class="number">
          {{ formattedValue }}
        </div>
      </transition>
    </div>
  </template>
  
  <script setup lang="ts">
  import { computed } from 'vue';
  
  const props = defineProps<{
    value: string;
  }>();
  
  const formattedValue = computed(() => props.value);
  </script>
  
  <style scoped>
  .flip-unit {
    perspective: 1000px;
    width: 1.2em;
    height: 1.2em;
    position: relative;
    font-size: 4em;
  }
  
  .number {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: white;
    border-radius: 0.1em;
    color: #333;
    transform-style: preserve-3d;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  }
  
  .flip-enter-active {
    animation: flip-in 0.6s ease-out;
  }
  
  .flip-leave-active {
    animation: flip-out 0.6s ease-in;
  }
  
  @keyframes flip-in {
    from {
      transform: rotateX(90deg);
    }
    to {
      transform: rotateX(0deg);
    }
  }
  
  @keyframes flip-out {
    from {
      transform: rotateX(0deg);
    }
    to {
      transform: rotateX(+90deg);
    }
  }
  </style>